<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="keyword" content="">

    <title>审批人 - 流程设定</title>

    <!-- Bootstrap core CSS -->
    <link href="__PUBLIC__/css/bootstrap.min.css" rel="stylesheet">
    <link href="__PUBLIC__/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="__PUBLIC__/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="__PUBLIC__/css/style.css" rel="stylesheet">
    <link href="__PUBLIC__/css/style-responsive.css" rel="stylesheet" />
    <!-- new styles-->
      <link href="__PUBLIC__/css/xxxstyle.css" rel="stylesheet" />

      <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
      <script src="__PUBLIC__/js/html5shiv.js"></script>
      <script src="__PUBLIC__/js/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>
  <section id="container" class="">
      <!--main content start-->
      <section id="main-content">
          <section class="wrapper site-min-height">
              <!-- page start-->
              <section class="panel pageRangeA">
                  <div class="panel-heading">
                      <i class="icon-paste"></i>审批人
                      <span class="pull-right">
                          <button type="button" class="btn btn-default btn-xs" onclick="javascript:window.history.back();return false;"><i class="icon-reply"></i>返回</button>
                      </span>
                  </div>
                  <div class="panel-body">
                     <foreach name="ename" item="vv" key="kk">
                      <div class="approverBox">
                          <div class="pull-left">
                              <span class="approverCircle">{$vv.examine_name}</span>
                          </div>
                          <div class="approverSelect">
                           <if condition="$vv['examine_name'] eq '发起方'">
                                <!-- <span data-toggle="modal"  href="#copyer"  style="cursor:hand">点此设置发起人 </span> -->
                                <select class="selectpicker" data-live-search="true" multiple data-max-options="5" id="s">
                                  <foreach name="user" item="y" key="j">
                                      <optgroup label="{$y.cat_name}">
                                        <foreach name="y.user" item="v" key="k">
                                          <option data-tokens="{$v.name}-{$v['post']}" value="{$v.admin_id}" {:in_array($v['admin_id'],$se) ? 'selected="selected"' : ''}>{$v.name}-{$v['post']}</option>
                                        </foreach>
                                      </optgroup>
                                  </foreach>
                                </select>
                           <else/>
                           	 <select class="selectpicker" data-live-search="true" id="d">
                                <option value="{$vv.examine_name}" style="display: none;">请选择</option>
                           	    <foreach name="user" item="y" key="j">
                                  <optgroup label="{$y.cat_name}">
      	                            <foreach name="y.user" item="v" key="k">
  									          <option data-tokens="{$v.name}-{$v['post']}" value="{$v.admin_id}.{$vv.id}" <if condition="$vv['id'] eq $v['eid']">selected="selected"</if>>{$v.name}-{$v['post']}</option>
						                  </foreach>
						                </optgroup>
				                </foreach>
                             </select>
                           </if>
                          </div>
                            <if condition="$kk lt count($ename)-1">
                          <div class="approverArrow">
                              <i class="icon-long-arrow-right"></i>
                          </div>
							</if>
                      </div>
                      </foreach>
                      <div class="approverLine">
                          <button class="btn btn-submit" type="submit" onclick="saveapproval()">{:empty($se['launch']) ? '保存设置' : '重新设定'}</button>
                      </div>
                  </div>
              </section>
              <!-- page end-->
          </section>
      </section>
      <!--main content end-->
  </section>

    <!-- js placed at the end of the document so the pages load faster -->
    <script src="__PUBLIC__/js/jquery.js"></script>
    <!-- <script src="__PUBLIC__/js/jquery-1.8.3.min.js"></script> -->
    <script src="__PUBLIC__/js/bootstrap.min.js"></script>
    <script class="include" type="text/javascript" src="__PUBLIC__/js/jquery.dcjqaccordion.2.7.js"></script>
    <script src="__PUBLIC__/js/jquery.scrollTo.min.js"></script>
    <script src="__PUBLIC__/js/jquery.nicescroll.js" type="text/javascript"></script>
    <script src="__PUBLIC__/js/jquery.customSelect.min.js" ></script>

    <!--common script for all pages-->
    <script src="__PUBLIC__/js/common-scripts.js"></script>

    <!--new script for this page only-->
    <script src="__PUBLIC__/js/bootstrap-select.js"></script>
     <script type="text/javascript" src="__PUBLIC__/js/layer/layer.js"></script>
  <script>
      //保存设置
      function saveapproval(){
    	  var typeid = {$typeid};
    	  var engs = $("#d option");
    	  var s = $("#s option");
    	  //判读多选
       	  if(s.is(":selected")){
              var ss = [];
              for(var k in s){
                  if(s[k].selected){
                	  var sid = s[k].value;
                		  ss.push(sid);
                  }
              }
          }else{
       		  layer.msg("请选择发起方人员",{icon:2});
       		  return;
          } 
       	  //判读单选人员
    	  if(engs.is(":selected")){
              var eng = [];
              for(var k in engs){
                  if(engs[k].selected){
                	  var eid = engs[k].value;
                	  if(eid=='内审2' || eid=='内审3' || eid =='审核2' || eid == '审核3'){
                		  continue;
                	  }
            	      if(isNaN(eid)){
                		  layer.msg("请选择"+eid+"人员",{icon:2});
                		  return;
                	  }else{
                		  eng.push(eid);
                	  }
                  }
              }
          }
          if(eng == undefined || eng == '' || ss == undefined || ss== ''){
        	  layer.msg('数据有误,请刷新重试',{icon:2});
    		  return;
          }
          if(typeid == ''){
        	  layer.msg('数据id有误,请刷新重试',{icon:2});
    		  return;
          }
        $.ajax({
		 		type : 'post',
		 		url : '__URL__/saveapproval',
		 		data : {examine:eng,typeid:typeid,launch:ss},
		 		dataType : 'json',
		 		success : function(res){
		 			 if(res.status==0){
							layer.alert(res.info, {icon: 2});
							return;
						 }
		 			 if(!res.errNo){
		 				 layer.msg(res.msg,{icon:1});
		 				 setTimeout('self.location.href="/System/definition"',2000);
			         }else{
			        	 layer.msg(res.msg,{icon:2});
			         }
		 		}
		     })
      }
      
  </script>
  </body>
</html>
